/*
 * @Author: GaoD 
 * @Date: 2022-01-17 12:55:10 
 * @Last Modified by: GaoD
 * @Last Modified time: 2022-01-17 13:33:50
 *      路由
 */
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    component: () => import('@/views/Login/Login'),
    meta: { isPublic: true }
  }
  ,
  {
    path: '/',
    component: () => import('@/views/Layout/Layout'),
    redirect: '/home',
    children: [
      {
        path: '/home',
        component: () => import('@/views/Home/Home')
      },

    ]
  },
  {
    path: '/person',
    component: () => import('@/views/Layout/Layout'),
    redirect: '/person/person-info',
    children: [
      {
        path: 'person-info',
        component: () => import('@/views/PersonInfo/PersonInfo')
      }
    ]
  },
  {
    path: '*',
    component: () => import('@/views/Err404/Err404')
  }
]

const router = new VueRouter({
  routes
})

router.beforeEach((to, from, next) => {
  // if (!to.meta.isPublic && !localStorage.token){
  //   return next('/login')
  // }
  console.log(to.meta);

  next();
})

export default router
